package auctionhaus



import grails.test.mixin.*
import org.junit.*
import grails.test.ControllerUnitTestCase

/**
 * See the API for {@link grails.test.mixin.web.ControllerUnitTestMixin} for usage instructions
 */
@TestFor(ListingController)
@Mock([Listing, Customer])
class ListingControllerTests {
    def seller
    def listing1

    public void setUp() {
        seller = new Customer(email: "johndoe@acme.com", password: "asdfqw")
        seller.save(flush: true)

        listing1 = new Listing(id: 1, name: "listing 1", endTime: new Date()+1, startBid: 5, seller: seller)
        listing1.save(flush: true)
    }

    void testAddBid() {
        def controller = new ListingController()
        controller.params.id = listing1.id
        controller.addBid()
        assert controller.response.redirectUrl.equalsIgnoreCase("/bid/create/1?listing.id=1")
    }

    public void tearDown(){
        seller = null
        listing1 = null
    }
}
